package cn.edu.buu.news.service.impl;

import cn.edu.buu.news.entity.Task;
import cn.edu.buu.news.mapper.TaskMapper;
import cn.edu.buu.news.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

@Service
@Transactional
public class TaskServiceImpl implements TaskService {

    @Autowired
    private TaskMapper taskMapper;

    @Override
    public void add(Task task) {
        taskMapper.insert(task);
    }

    @Override
    public void deleteById(Long task_id) {
        taskMapper.deleteById(task_id);
    }

    @Override
    public void update(Task task) {
        taskMapper.update(task);
    }

    @Override
    @Transactional(readOnly = true)
    public Task findById(Long task_id) {
        return taskMapper.selectById(task_id);
    }

    @Override
    @Transactional(readOnly = true)
    public List<Task> findAll() {
        return taskMapper.selectAll();
    }
}